using System;
using BCW.Friends;
using I2.Loc;

public class RocketLeagueGameMode : TeamGameMode
{
	public override bool IsAutoStart()
	{
		return true;
	}

	public override void StartRound()
	{
		StartRoundWithAction(null);
	}

	public override bool CanStartNow()
	{
		return base.CanStartNow() && (RocketLeagueCotroller.instance == null || !RocketLeagueCotroller.instance.inRestartWindow);
	}

	public override void RestartRound()
	{
		if (GameController.instance.playerScript != null)
		{
			GameController.instance.playerScript.Points = 0;
		}
		TDMController.instance.WaitTeamAndSpawnPointOnRestart(RestartRocketLeague);
	}

	public override void EndRound()
	{
		RocketLeagueCotroller.instance.inRestartWindow = true;
		GameController.instance.arrAllCar.ForEach(delegate(EntityBehavior car)
		{
			car.HideCrown();
		});
		TDMController.instance.RestartTDM();
	}

	private void RestartRocketLeague()
	{
		base.RestartRound();
		RocketLeagueCotroller.instance.OnRestartGame();
		if (FriendsUIGame.instance != null)
		{
			FriendsUIGame.instance.CleanInvitePlayer();
		}
		GameInfoWindow.instance.ShowStartGameWindow();
		RocketLeagueCotroller.instance.StartGame();
	}

	public void StartRoundWithAction(Action onStart)
	{
		base.StartRound();
		GameInfoWindow.instance.TurnLoadAnimation(true);
		GameInfoWindow.instance.InitResultWindow();
		PlayerBehavior.MyPlayer.FirstSpawn(2f);
		CoroutineRunner.Invoke(2.5f, delegate
		{
			GameInfoWindow.instance.HideInterface();
			GameController.instance.showWindowGame();
			if (onStart != null)
			{
				onStart();
			}
		});
	}

	public override string EndGameModeTitle()
	{
		return ScriptLocalization.Get("Game_Common/rocket_over");
	}
}
